package com.mzy.basics.Enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Ives
 * * @date 2022/1/18
 */

/**
 * 通过枚举类的code，拿到枚举类的名字
 */
@Getter
@AllArgsConstructor
public enum EchannelMsgBizCategoryEnum {
  BROADCAST_MESSAGE("broadcastMessage", "广播消息"),
  SPECIAL_MESSAGE("specialMessage", "特殊通知"),
  PRIVATE_MESSAGE("privateMessage", "个人消息"),
  ;
  private String code;
  private String name;


  public static EchannelMsgBizCategoryEnum getEchannelMsgBizCategoryEnum(String code) {
    for(EchannelMsgBizCategoryEnum categoryEnum : EchannelMsgBizCategoryEnum.values()) {
      if(categoryEnum.getCode().equalsIgnoreCase(code)) {
        return categoryEnum;
      }
    }
    return null;
  }

  public static void main(String[] args) {
    EchannelMsgBizCategoryEnum echannelMsgBizCategoryEnum = getEchannelMsgBizCategoryEnum("privateMessage");
    System.out.println(echannelMsgBizCategoryEnum);
  }
}